<template>
	<view>
		小程序跳转中间页面
	</view>
</template>
<script setup lang="ts">
import { onLoad } from "@dcloudio/uni-app"
import { useStore } from 'vuex'
const store = useStore()

onLoad((options)=>{
	let loginInfo = JSON.parse(decodeURIComponent(options.loginInfo))
	
	if(loginInfo){
		store.dispatch('logOut');
		uni.setStorageSync('accessToken', loginInfo.accessToken);
		uni.setStorageSync('userId', loginInfo.userId);
		uni.setStorageSync('userPhone', loginInfo.userPhone);
		uni.setStorageSync('tenentId',loginInfo.tenentId);
		uni.setStorageSync('expiresTime',loginInfo.expiresTime);
		uni.setStorageSync('refreshToken',loginInfo.refreshToken);
		store.dispatch('setLoginData', loginInfo);
	}
	setTimeout(() => {
		let token = uni.getStorageSync('accessToken')
		if(token){
			uni.redirectTo({
				url: decodeURIComponent(options.url)
			})
		}else{
			uni.redirectTo({
				url:`/pages/login/login?form=internal?url=${decodeURIComponent(options.url)}`
			})
		}
	},500)
})
</script>
<style lang="scss" scoped>

</style>